package algorithm.leetcode.I1400above;


/**
 * result = [a0, a1, a2, ... , an]
 * encode = [a0^a1, a1^a2, ... , an-1^an]
 * 利用 ai^ai^ai+1=ai+1 即可
 */

public class Q1720 {

    public int[] decode(int[] encoded, int first) {
        int[] res = new int[encoded.length+1];
        res[0] = first;
        for (int i = 1; i < res.length; i++) {
            res[i] = res[i-1] ^ encoded[i-1];
        }
        return res;
    }

}
